#include "string"
#include "iostream"
#include "vector"
#include "typeinfo"
#include "memory"
using namespace std;

class Colleage;

class Mediator
{
protected:
    vector<Colleage*> colleage_list;
public:
    void AddColleage(Colleage* colleage_){
        colleage_list.push_back(colleage_);
    };
    virtual void colleageChange(class Colleage* c){};
};


class Colleage
{
public: 
    Colleage(string name):name_(name){}
    void SetMediator(class Mediator* mediator){
        mediator_ = mediator;
    }
    void change(){
        mediator_->colleageChange(this);
    }
    string GetName()
    {
        return name_;
    }

    virtual void dosomething_t(){}
protected:
    class Mediator* mediator_;  
private:
    string name_;
};



class ConcretMediator:public Mediator
{

public: 
    void colleageChange(class Colleage* c)
    {
        c->dosomething_t();
    }
};


class ConcretColleage:public Colleage
{
public:
    ConcretColleage(string name):Colleage(name){}
    void dosomething_t(){
        cout<<this->GetName()<<endl;
    }
};

int main()
{
    ConcretMediator* mediator = new ConcretMediator();
    ConcretColleage* dog = new ConcretColleage("dog");
    ConcretColleage* cat = new ConcretColleage("cat");

    mediator->AddColleage(dog);
    mediator->AddColleage(cat);

    dog->SetMediator(mediator);
    cat->SetMediator(mediator);

    dog->change();
    cat->change();

}